<%--
  Created by IntelliJ IDEA.
  User: 你忙吧t233
  Date: 2021/10/20
  Time: 9:32
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <title>Title</title>
</head>
<style>
    body{
     background-color: cornsilk;
    }
    .zengjia{
        position: absolute;
        right: 40%;
        top: 5%;

    }
    .biaoge{
        position: absolute;
        left: 35%;
        top: 10%;
    }
</style>
<body>
<div class="all">
    <div class="zengjia">
        <a href="insert.jsp">新增联系人</a>
    </div>

    <div class="biaoge">

        <table border="1">
            <tr>
                <td>姓名</td>
                <td>电话</td>
                <td>邮箱</td>
                <td>关系</td>
                <td>操作</td>
            </tr>
            <c:forEach items="${list}" var="list">
                <tr>
                    <td>${list.a_name}</td>
                    <td>${list.a_phone}</td>
                    <td>${list.a_mail}</td>
                    <td>${list.a_relation}</td>
                    <td><a href="delete?id=${list.a_id}">删除</a></td>
                </tr>
            </c:forEach>
        </table>
        <a href="show?pageNum=1">首页</a>
        <a href="show?pageNum=${page.pageNum-1}" id="up">上一页</a>
        <a href="show?pageNum=${page.pageNum+1}" id="next">下一页</a>
        <a href="show?pageNum=${page.pages}">尾页</a>
    </div>
</div>


</body>
</html>
<script>
    var arr = document.getElementsByTagName("tr");
    for(var i=0;i<arr.length;i++){
        if (i%2==0){
            arr[i].style.backgroundColor="yellow";
        }
    };
    if (${page.pageNum==1}){
        document.getElementById("up").style.display="none";
    };
    if (${page.pageNum==page.pages}){
        document.getElementById("next").style.display="none";
    }

</script>